<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .is-fail{
            font-size: 30px;
            color: red;
        }
        .is-ok{
            font-size: 30px;
            color: red;
        }
    </style>
</head>
<body>
    <input class="input" type="text" placeholder="请输入一个基数">
    <p class="msg"></p>
    <button class="btn">验证</button>
    <script>
        var btn = document.querySelector('.btn');
        var msg = document.querySelector('.msg');
        btn.onclick = function () {
            var pValue = '';
            var input = document.querySelector('input');
            var value = input.value;

            if (value%2 === 0) {
                pValue = '不是奇数！！！';
                if (msg.classList.contains('is-ok')) {
                    msg.classList.remove('is-ok');
                }
                    msg.classList.add('is-fail');
            } else {
                pValue = '恭喜你';
                if (msg.classList.contains('is-fail')) {
                    msg.classList.remove('is-fail');
                }
                    msg.classList.add('is-ok');
            }

            msg.innerText = pValue;
        }
    </script>
</body>
</html>